import { useLocation } from 'react-router-dom';
import { NEWS_MENU_TYPE_ENUM } from './type';

/** 获取 URL 参数中的类型 */
export const useType = () => {
  const location = useLocation();
  const searchParams = new URLSearchParams(location.search);
  const type = searchParams.get('type');
  if (type) {
    return type as NEWS_MENU_TYPE_ENUM;
  }
  return NEWS_MENU_TYPE_ENUM.KEYAN;
}